// this is the townscript for town 14: Ceremony caves

begintownscript;

variables;

int choice;

body;

beginstate INIT_STATE;
	
	set_crime_tolerance(3);
	
	set_flag(14,2,0);
	
break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;
break;

beginstate 10;
if (get_flag(13,5) == 1) {
	if (get_flag(14,0) == 1)
			end();
		reset_dialog();
		add_dialog_str(0,"This is the altar where you are probably supposed to perform the ritual. You feel an urge to kneel. Do you?",0);
		add_dialog_choice(0,"Kneel");
		add_dialog_choice(1,"Keep standing");
		choice = run_dialog(1);
		if (choice == 1) {
				reset_dialog();
				add_dialog_str(0,"You kneel down. A powerful force starts getting up from your knees, to your legs and eventually fills your body. Your start screaming from pain. A few moments later, everything calms down. The altar is glowing faintly.",0);
				add_dialog_str(1,"After a few moments of resting, the peace and quiet is heavily disturbed by a voice: _You did the ceremony. The shade of Dakrach lets you free. Now go away, I've got a splitting headache._",0);
				add_dialog_choice(0,"Go away");
				add_dialog_choice(1,"Insult the voice for being not nice");
				choice = run_dialog(1);
				set_flag(14,0,1);
				award_party_xp(50,20);
				if (choice == 2) {
						message_dialog("You start screaming at the top of your voices, cursing and swearing heavily. It doesn't seem to help, as nothing happens. However, as you continue with your tirade, the voice responds in a most painful fashion.","");
						put_boom_on_char(0,1,0);
						put_boom_on_char(1,1,0);
						put_boom_on_char(2,1,0);
						put_boom_on_char(3,1,0);
						put_boom_on_char(4,1,0);
						put_boom_on_char(5,1,0);
						run_animation_sound(5);
						run_animation();
						change_char_health(0,-50);
						change_char_health(1,-50);
						change_char_health(2,-50);
						change_char_health(3,-50);
						change_char_health(4,-50);
						change_char_health(5,-50);
						change_char_health(6,-50);
						}
				}
		}
break;

beginstate 11;
	reset_dialog();
	add_dialog_str(0,"This teleporter will probably bring you to the ceremony halls. Do you want to go in?",0);
	add_dialog_choice(0,"Enter teleporter.");
	add_dialog_choice(1,"Leave");
	choice = run_dialog(1);
	if (choice == 1) {
		message_dialog("You step into the portal. You see lovely colors all around you, until everything becomes black again. You are there.","");
		teleport_party(27,8,0);
		}
break;

beginstate 12;
	reset_dialog();
	add_dialog_str(0,"This teleporter will probably bring you back to the preparation halls. Do you want to go in there?",0);
	add_dialog_choice(0,"Enter teleporter.");
	add_dialog_choice(1,"Leave");
	choice = run_dialog(1);
	if (choice == 1) {
		message_dialog("You step into the portal. You see lovely colors all around you, until everything becomes black again. You are back.","");
		teleport_party(20,8,0);
		}
break;

beginstate 13;
	reset_dialog();
	add_dialog_str(0,"You sit in front of a dark-yellow pool of strange liquid. You have no idea what to do with it. What would you like to do?",0);
	add_dialog_choice(0,"Drink it");
	add_dialog_choice(1,"Touch it");
	add_dialog_choice(2,"Do nothing");
	choice = run_dialog(1);
		if (choice == 1)
				message_dialog("You drink from the liquid it. You get a very nasty bellyache, but nothing else happens.","");
		if (choice == 2) {
				message_dialog("When you just touch the water it starts glowing. Apparently, you made the right choice. A new power settles in your body.","");
				if (get_flag(14,1) == 0) {
						set_flag(14,1,1);
						end();
						}
				}
break;

beginstate 14;
if (get_flag(14,1) == 4) {
	if (get_flag(14,2) == 1)
			end();
		message_dialog("The gate opens in front of you. That water did something to you, which enabled you to open the gate. Or at least, that's what you think.","This is confirmed when a voice says: _You are properly prepared. You may pass._");
		play_sound(106);
		play_sound(99);
		flip_terrain(14,8);
		set_flag(14,2,1);
		end();
		}
	message_dialog("The gate remains closed. When you turn back, however, a voice begins to speak:","_You, mortals, haven't prepared yourselves properly. Go back to the sign at the left and do the preparations a second time._ Everything is silent again.");
break;

beginstate 15;
	move_to_new_town(13,3,3);
break;

beginstate 16;
	reset_dialog();
	add_dialog_str(0,"This book doesn't look like anything particularly special. Its not a spell book, that's for sure. You could read it anyhow.",0);
	add_dialog_choice(0,"Read it");
	add_dialog_choice(1,"Leave it");
	choice = run_dialog(1);
	if (choice == 1)
		message_dialog("You begin reading. This book only contains notes, as far as you can see. However, there's something interesting here:","_I finally managed to understand how to open the gate! First I should go into the rooms on my left, then the ones on my right. I actually follow the dials of a clock._");
break;

beginstate 17;
	reset_dialog();
	add_dialog_str(0,"You sit in front of a heavenly-like blue pool of strange liquid. You have no idea what to do with it. What would you like to do?",0);
	add_dialog_choice(0,"Drink it");
	add_dialog_choice(1,"Touch it");
	add_dialog_choice(2,"Do nothing");
	choice = run_dialog(1);
		if (choice == 1)
				message_dialog("You drink from the liquid it. You get a very nasty bellyache, but nothing else happens","");
		if (choice == 2) {
				message_dialog("When you just touch the water it starts glowing. Apparently, you made the right choice. A new power settles in your body.","");
				if (get_flag(14,1) == 1) {
						set_flag(14,1,2);
						end();
						}
				}
break;

beginstate 18;
	reset_dialog();
	add_dialog_str(0,"You sit in front of a light-yellow pool of strange liquid. You have no idea what to do with it. What would you like to do?",0);
	add_dialog_choice(0,"Drink it");
	add_dialog_choice(1,"Touch it");
	add_dialog_choice(2,"Do nothing");
	choice = run_dialog(1);
		if (choice == 1)
			message_dialog("You drink from the liquid it. You get a very nasty bellyache, but nothing else happens","");
		if (choice == 2) {
				message_dialog("When you just touch the water it starts glowing. Apparently, you made the right choice. A new power settles in your body.","");
				if (get_flag(14,1) == 2) {
						set_flag(14,1,3);
						end();
						}
				}
break;

beginstate 19;
	reset_dialog();
	add_dialog_str(0,"You sit in front of a slightly off-blue pool of strange liquid. You have no idea what to do with it. What would you like to do?",0);
	add_dialog_choice(0,"Drink it");
	add_dialog_choice(1,"Touch it");
	add_dialog_choice(2,"Do nothing");
	choice = run_dialog(1);
		if (choice == 1)
				message_dialog("You drink from the liquid it. You get a very nasty bellyache, but nothing else happens","");
		if (choice == 2) {
				message_dialog("When you just touch the water it starts glowing. Apparently, you made the right choice. A new power settles in your body.","");
				if (get_flag(14,1) == 3) {
						set_flag(14,1,4);
						end();
						}
				}
break;

beginstate 20;
if (get_flag(14,3) == 1)
		end();
	message_dialog("This corridor has an enormous amount of blood. Whatever is in that corridor, it can't be good. Proceed with caution.","");
	set_flag(14,3,1);
break;

beginstate 21;
if (get_flag(14,4) == 1)
		end();
	message_dialog("In this room once bodies were cleaned as to prepare them for the burying ritual. It looks though, as if some of the body's weren't quite put to rest.","");
	set_flag(14,4,1);
break;

beginstate 22;
if (get_flag(14,5) == 1)
		end();
	message_dialog("In this chamber tombs were made. Some tombs are still standing along the walls. Also the descriptions to be put on the tombs were made here. Some undead didn't want to stay in their sarcophagus though. They would rather attack you.","");
	set_flag(14,5,1);
break;

beginstate 23;
if (get_flag(14,6) == 0) {
		message_dialog("You walk past some trees in a garden. There is something strange about them, though...","The first tree has dark-yellow leaves, the second a heavenly-blue sort of color, the third light-yellow, and the fourth an other sort of blue. You have never seen something like it, it's quite weird to look at.");
		set_flag(14,6,1);
		}
break;